<?php
/* -------------------------------------------------------------------------------------
* 	ID:						$Id: admin.php 140 2013-09-22 07:44:23Z phone.mueller@googlemail.com $
* 	Letzter Stand:			$Revision: 140 $
* 	zuletzt geaendert von:	$Author: siekiera $
* 	Datum:					$Date: 2013-09-22 07:44:23 +0000 (Sun, 22 Sep 2013) $
*
* 	SEO:mercari by Siekiera Media
* 	http://www.seo-mercari.de
*
* 	Copyright (c) since 2011 SEO:mercari
* --------------------------------------------------------------------------------------
* 	based on:
* 	(c) 2000-2001 The Exchange Project  (earlier name of osCommerce)
* 	(c) 2002-2003 osCommerce - www.oscommerce.com
* 	(c) 2003     nextcommerce - www.nextcommerce.org
* 	(c) 2005     xt:Commerce - www.xt-commerce.com
*
* 	Released under the GNU General Public License
* ----------------------------------------------------------------------------------- */

if($_SESSION['customers_status']['customers_status_id'] == 0) {
	$box_smarty = new Smarty();
	$box_admin='';
	
	$box_smarty->assign('tpl_path','templates/'.CURRENT_TEMPLATE.'/');
	$box_smarty->assign('html_tpl_path', CURRENT_TEMPLATE.'/html');
	
	function getMenuID($name) {
			global $db;
			$id = $db->db_query("SELECT
										parent_id
									FROM
										".TABLE_ADMIN_MENU."
									WHERE
										menu_name = '".$name."'", true);
			if($id->_numOfRows)
				return 'menu='.$id->fields['parent_id'];
		}
	
	$orders_contents = '';
	$site = '&'.getMenuID('orders');
	
	$orders_status_validating = $db->db_query("SELECT
													orders_status
												FROM
													".TABLE_ORDERS ."
												WHERE
													orders_status ='0'");

	$orders_contents .='<a href="'.href_link_admin(FILENAME_ORDERS, 'selected_box=customers&status=0'.$site, 'SSL').'">'.TEXT_VALIDATING.'</a>: '.$orders_status_validating->_numOfRows.'<br />';

	$orders_status = $db->db_query("SELECT
										orders_status_name,
										orders_status_id
									FROM
										".TABLE_ORDERS_STATUS."
									WHERE
										language_id = '".(int)$_SESSION['languages_id']."'
									ORDER BY
										orders_status_id ASC");

	while(!$orders_status->EOF) {
		$orders_pending = $db->db_query("SELECT
											count(orders_id) AS count
										FROM
											".TABLE_ORDERS."
										WHERE
											orders_status = '".$orders_status->fields['orders_status_id']."'");

		$orders_contents .= '<a href="'.href_link_admin(FILENAME_ORDERS, 'selected_box=customers&status='.$orders_status->fields['orders_status_id'].$site, 'SSL').'">'.$orders_status->fields['orders_status_name'].'</a>: '.$orders_pending->fields['count'].'<br />';
		$orders_status->MoveNext();
	}
	$orders_contents = substr($orders_contents, 0, -6);

	$customers = $db->db_query("SELECT COUNT(customers_id) AS count FROM ".TABLE_CUSTOMERS);
	$products = $db->db_query("SELECT COUNT(products_id) AS count FROM ".TABLE_PRODUCTS." WHERE products_status = '1'");
	$reviews = $db->db_query("SELECT COUNT(reviews_id) AS count FROM ".TABLE_REVIEWS);
	
	if($product->isProduct())
		$edit_product = '<li><a href="'.href_link_admin(FILENAME_EDIT_PRODUCTS, 'cPath='.get_product_path($product->data['products_id']).'&pID='.$product->data['products_id'].'&'.getMenuID('categories')).'&action=new_product'.'">'.IMAGE_BUTTON_PRODUCT_EDIT.'</a><li>';

	$box_admin = '	<ul>
						<li class="box_admin_status_head">
							<span>Status</span>
							<div class="box_admin_status_body dn al">'.$orders_contents.'</div>
						</li>
						<li>'.BOX_ENTRY_CUSTOMERS.': '.$customers->fields['count'].'</li>
						<li>'.BOX_ENTRY_PRODUCTS.': '.$products->fields['count'].'</li>
						<li>'.BOX_ENTRY_REVIEWS.': '.$reviews->fields['count'].'</li>
						<li>
							<a class="admin_link" href="'.href_link(FILENAME_START, '', 'SSL').'">'.IMAGE_BUTTON_ADMIN.'</a>
						</li>'.
						$edit_product.'
						<li class="li_del_cache">
							<a class="no_target del_cache" href="#">Cache leeren</a>
						</li>
					</ul>';
	$get[] = 'box=admin';
	$box_smarty->assign('BOX_CONTENT', $box_admin);

	$box_smarty->caching = false;
	$box_smarty->assign('language', $_SESSION['language']);
	$box_content = $box_smarty->fetch(CURRENT_TEMPLATE.'/boxes/box_admin.html');
}